package com.ruoyi.squadweb.service.impl;

import java.util.ArrayList;
import java.util.List;

import com.ruoyi.common.core.domain.entity.SysRole;
import com.ruoyi.common.core.domain.entity.SysUser;
import com.ruoyi.squadweb.domain.SquadjsServiceList;
import com.ruoyi.squadweb.mapper.SquadjsServiceListMapper;
import com.ruoyi.squadweb.service.ISquadjsServiceListService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 * 服务器列表信息Service业务层处理
 *
 * @author LJY
 * @date 2023-10-19
 */
@Service
public class SquadjsServiceListServiceImpl implements ISquadjsServiceListService
{
    @Autowired
    private SquadjsServiceListMapper squadjsServiceListMapper;

    /**
     * 查询服务器列表信息
     *
     * @param id 服务器列表信息主键
     * @return 服务器列表信息
     */
    @Override
    public SquadjsServiceList selectSquadjsServiceListById(Long id)
    {
        return squadjsServiceListMapper.selectSquadjsServiceListById(id);
    }

    /**
     * 查询服务器列表信息列表
     *
     * @param squadjsServiceList 服务器列表信息
     * @return 服务器列表信息
     */
    @Override
    public List<SquadjsServiceList> selectSquadjsServiceListList(SquadjsServiceList squadjsServiceList)
    {
        return squadjsServiceListMapper.selectSquadjsServiceListList(squadjsServiceList);
    }

    /**
     * 新增服务器列表信息
     *
     * @param squadjsServiceList 服务器列表信息
     * @return 结果
     */
    @Override
    public int insertSquadjsServiceList(SquadjsServiceList squadjsServiceList)
    {
        return squadjsServiceListMapper.insertSquadjsServiceList(squadjsServiceList);
    }

    /**
     * 修改服务器列表信息
     *
     * @param squadjsServiceList 服务器列表信息
     * @return 结果
     */
    @Override
    public int updateSquadjsServiceList(SquadjsServiceList squadjsServiceList)
    {
        return squadjsServiceListMapper.updateSquadjsServiceList(squadjsServiceList);
    }

    /**
     * 批量删除服务器列表信息
     *
     * @param ids 需要删除的服务器列表信息主键
     * @return 结果
     */
    @Override
    public int deleteSquadjsServiceListByIds(Long[] ids)
    {
        return squadjsServiceListMapper.deleteSquadjsServiceListByIds(ids);
    }

    /**
     * 删除服务器列表信息信息
     *
     * @param id 服务器列表信息主键
     * @return 结果
     */
    @Override
    public int deleteSquadjsServiceListById(Long id)
    {
        return squadjsServiceListMapper.deleteSquadjsServiceListById(id);
    }

    @Override
    public List<SquadjsServiceList> selectServiceAll() {
        return squadjsServiceListMapper.selectSquadjsServiceListList(null);
    }

    @Override
    public List<SquadjsServiceList> getRoleService(SysUser user) {
        List<Long> roleIds = new ArrayList<>();
        for (SysRole role : user.getRoles()) {
            roleIds.add(role.getRoleId());
        }
        if (roleIds.size() == 0) {
            return new ArrayList<>();
        }
        return squadjsServiceListMapper.getRoleService(roleIds);

    }

}
